﻿using Sustainalytics.LongRunningTaskManager.Interface;
using System.Collections.Generic;

namespace Sustainalytics.LongRunningTaskManager
{
    /// <summary>
    /// Task result as an object.
    /// </summary>
    public class LongRunningTaskObjectResult : ILongRunningTaskResult, IEqualityComparer<LongRunningTaskObjectResult>
    {
        /// <summary>
        /// Task result type.
        /// </summary>
        public LongRunningTaskResultTypeEnum Type
        {
            get { return LongRunningTaskResultTypeEnum.Object; }
        }

        /// <summary>
        /// Result data.
        /// </summary>
        public object Data { get; set; }


        public bool Equals(ILongRunningTaskResult x, ILongRunningTaskResult y)
        {
            if (x == null && y == null)
                return true;

            if (x == null || y == null)
                return false;

            if (x.GetType() != typeof(LongRunningTaskObjectResult) || x.GetType() != y.GetType())
                return false;

            return this.Equals((LongRunningTaskObjectResult)x, (LongRunningTaskObjectResult)y);
        }

        public int GetHashCode(ILongRunningTaskResult obj)
        {
            return this.GetHashCode(obj);
        }


        public bool Equals(LongRunningTaskObjectResult x, LongRunningTaskObjectResult y)
        {
            if (x == null && y == null)
                return true;

            if (x == null || y == null)
                return false;

            return true;
        }

        public int GetHashCode(LongRunningTaskObjectResult obj)
        {
            return 0;
        }
    }
}
